<?php

namespace App\Exceptions;

use Illuminate\Auth\AuthenticationException;
use Illuminate\Contracts\Support\Responsable;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Routing\Route;
use Illuminate\Validation\ValidationException;
use Throwable;

class Handler extends ExceptionHandler
{
    /**
     * A list of the exception types that are not reported.
     *
     * @var string[]
     */
    protected $dontReport = [
        //
    ];

    /**
     * A list of the inputs that are never flashed for validation exceptions.
     *
     * @var string[]
     */
    protected $dontFlash = [
        'current_password',
        'password',
        'password_confirmation',
    ];

    /**
     * Register the exception handling callbacks for the application.
     *
     * @return void
     */
    public function register()
    {
        $this->reportable(function (Throwable $e) {
            //
        });
    }

//    public function render($request, Throwable $e)
//    {
//        if (method_exists($e, 'render') && $response = $e->render($request)) {
//            return Route::toResponse($request, $response);
//        } elseif ($e instanceof Responsable) {
//            return $e->toResponse($request);
//        }
//
//        $e = $this->prepareException($this->mapException($e));
//        foreach ($this->renderCallbacks as $renderCallback) {
//            if (is_a($e, $this->firstClosureParameterType($renderCallback))) {
//                $response = $renderCallback($e, $request);
//
//                if (!is_null($response)) {
//                    return $response;
//                }
//            }
//        }
//        if ($e instanceof HttpResponseException) {
//            return $e->getResponse();
//        } elseif ($e instanceof AuthenticationException) {
//            return json_encode(['code' => 403, 'message' => $e->getMessage(), 'data' => []]);
////            return apiResponse(403, $e->getMessage());
//        } elseif ($e instanceof ValidationException) {
//            return $this->convertValidationExceptionToResponse($e, $request);
//        }
//        return json_encode(['code' => 403, 'message' => $e->getMessage(), 'data' => []]);
////        return apiResponse(500, $e->getMessage());
//    }
}
